<div class="layui-container fly-marginTop fly-user-main">
  {include file='common/UserMenu'/}

  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>
  
  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>
  
  
  <div class="fly-panel fly-panel-user" pad20>
    <!--
    <div class="fly-msg" style="margin-top: 15px;">
      您的邮箱尚未验证，这比较影响您的帐号安全，<a href="activate.html">立即去激活？</a>
    </div>
    -->
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li data-type="mine-jie" lay-id="index" class="layui-this">我的帖子（<span>{$total}</span>）</li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show">
          <ul class="mine-view jie-row">
            {if($PostList)}
            {foreach $PostList as $item}
              <li>
                <a class="jie-title" href="{:url('home/index/info',['postid' => $item.id])}" target="_blank">{$item.title}</a>
                <i>{$item.createtime}</i>
                {if(!$item['accept'])}
                <a class="mine-edit" href="{:url('home/post/edit',['postid' => $item.id])}" style="cursor: pointer;">编辑</a>
                {/if}
                <em>{$item.visit_total}阅/{$item.comment_total}答</em>
              </li>
            {/foreach}
            {else /}
            <div class="fly-none" style="min-height: 50px; padding:30px 0; height:auto;"><span>暂无帖子</span></div>
            {/if}
          </ul>
          {$PostList|raw}
        </div>
       
      </div>
    </div>
  </div>
</div>
<script>
  layui.use(['layer'],function(){

    var $ = layui.jquery,
    layer = layui.layer

    $(".CollectDel").on('click', function(){
      let that = $(this)
      layer.confirm('确认取消收藏该帖子？',{icon:3,title:'取消收藏'},function(index){
        let id = that.data('postid')
        // 发送异步请求
        $.ajax({
          url:`{:url('home/collection/add')}`,
          type:'post',
          data:{
            postid:id
          },
          dataType:'json',
          success:function(success)
          {
            if(success.code === 1)
            {
              // 成功
              layer.msg(success.msg, {
                icon: 1,
                time: 2000 // 2秒关闭（如果不配置，默认是3秒）
              }, function(){
                // 直接刷新界面
                location.reload()
              })
            }else
            {
              // 失败
              layer.msg(success.msg)
            }
          }
        })

        // 关闭窗口
        layer.close(index);

      })
        
    })
  })
</script>